/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package checker.sdchecker;

/**
 *
 * @author takeshi
 */
public class TestResult {

    private final long timeElapsed;
    private final long totalBytes;
    private final int totalFiles;
    private final long currentBytes;
    private final int currentFiles;

    public TestResult(long timeElapsed, long totalBytes, int totalFiles, long currentBytes, int currentFiles) {
        this.timeElapsed = timeElapsed;
        this.totalBytes = totalBytes;
        this.totalFiles = totalFiles;
        this.currentBytes = currentBytes;
        this.currentFiles = currentFiles;
    }

    /**
     * @return the speed in bytes per second
     */
    public double getSpeed() {
        if(timeElapsed == 0L) {
            return 0.0;
        }
        return (1000.0 * currentBytes) / (double) timeElapsed;
    }

    public long remaining() {
        double s = getSpeed();
        if(s == 0.0) {
            return -1;
        }
        long bytesRemaining = totalBytes - currentBytes;
        return (long) (bytesRemaining / s) * 1000L;
    }

    public long getCurrentBytes() {
        return currentBytes;
    }

    public int getCurrentFiles() {
        return currentFiles;
    }

    public long getTimeElapsed() {
        return timeElapsed;
    }

    public long getTotalBytes() {
        return totalBytes;
    }

    public int getTotalFiles() {
        return totalFiles;
    }
}
